package com.sodaopen.crm.customer.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.sodaopen.crm.common.entity.AjaxResult;
import com.sodaopen.crm.customer.service.ICustomerService;
import com.sodaopen.crm.customer.service.IRecordService;
import com.sodaopen.crm.customer.vo.CustomerVO;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author SodaJava
 * @since 2020-07-05
 */
@RestController
public class RecordController {

    @Autowired
    private IRecordService recordService;

    @Autowired
    private ICustomerService customerService;

    @GetMapping("/customers/{id}/records")
    public Object getRecords(@PathVariable("id") Integer id){
        CustomerVO customer = customerService.getCustomerByIdWithRecords(id);
        if(customer == null){
            return AjaxResult.NOT_FOUND("客户不存在！");
        }

        return AjaxResult.OK("查询成功！", customer);
    }
}
